package cn.zspt.fingerJoy.service.impl;

import cn.zspt.fingerJoy.domain.Seller;
import cn.zspt.fingerJoy.domain.Theme;
import cn.zspt.fingerJoy.domain.User;
import cn.zspt.fingerJoy.mapper.SellerMapper;
import cn.zspt.fingerJoy.mapper.ThemeMapper;
import cn.zspt.fingerJoy.mapper.UserMapper;
import cn.zspt.fingerJoy.service.FingerJoyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class FingerJoyServiceImpl implements FingerJoyService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ThemeMapper themeMapper;
    @Autowired
    private SellerMapper sellerMapper;
    public User login(User user){
        return userMapper.login(user);
    }

    public List<Theme> findAllTheme(){
        return themeMapper.findAllTheme();
    }

    public PageInfo<Seller> findSellerNear(int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<Seller> sellers=sellerMapper.findSellerNear();
        PageInfo<Seller> pageInfo = new PageInfo(sellers);
        return pageInfo;
    }

    public Seller findSellerById(int id){
        return sellerMapper.findSellerById(id);
    }

    public PageInfo<Seller> findSellerByKeyword(int pageNum, int pageSize,String keyword){
        PageHelper.startPage(pageNum, pageSize);
        List<Seller> sellers=sellerMapper.findSellerByKeyword(keyword);
        PageInfo<Seller> pageInfo = new PageInfo(sellers);
        return pageInfo;
    }

}
